#!/bin/sh

filename=$1

SYSTYPE=`uname`

AST=astyle

if   [ "${filename#*.}" = "c" ] || [ "${filename#*.}" = "cpp" ] \
  || [ "${filename#*.}" = "h" ] || [ "${filename#*.}" = "hpp" ] ;
then
	$AST --style=allman \
    --indent=spaces=2 \
    --indent-modifiers \
    --indent-classes \
    --indent-switches \
    --indent-namespaces \
    --indent-preproc-block \
    --indent-preproc-define \
    --indent-preproc-cond \
    --indent-col1-comments \
    --min-conditional-indent=2 \
    --max-instatement-indent=40 \
    --break-blocks \
    --pad-oper \
    --pad-paren \
    --pad-paren-in \
    --align-pointer=type \
    --align-reference=type \
    --suffix=none \
    --attach-return-type \
    --attach-return-type-decl \
    --formatted \
    --quiet \
    $filename >/dev/null

elif [ "${filename#*.}" = "v" ];
then
    iStyle -np $filename >/dev/null
fi
